﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace gvPoco.ChartOptions
{
    /// <summary>
    /// An object with members to configure various horizontal axis elements.
    /// </summary>
    public class HorizontalAxis
    {
        /// <summary>
        /// The baseline for the horizontal axis. This option is only supported for a continuous axis.
        /// </summary>
        public double baseline { get; set; }

        /// <summary>
        /// The color of the baseline for the horizontal axis. 
        /// Can be any HTML color string, for example: 'red' or '#00cc00'.
        /// This option is only supported for a continuous axis.
        /// </summary>
        public string baselineColor { get; set; }

        /// <summary>
        /// The direction in which the values along the horizontal axis grow. 
        /// Specify -1 to reverse the order of the values.
        /// </summary>
        private int _direction;
        public int direction
        {
            get { return _direction; }
            set 
            {
                if (value == 1 || value == -1)
                {
                    _direction = value;
                }
            }
        }

        /// <summary>
        /// A format string for numeric or date axis labels.
        /// </summary>
        public string format { get; set; }

        /// <summary>
        /// An object with members to configure the gridlines on the horizontal axis
        /// </summary>
        public GridLines gridlines { get; set; }

        /// <summary>
        /// An object with members to configure the minor gridlines on the horizontal axis, 
        /// similar to the hAxis.gridlines option.
        /// </summary>
        public GridLines minorGridlines { get; set; }

        /// <summary>
        /// hAxis property that makes the horizontal axis a logarithmic scale 
        /// (requires all values to be positive). Set to true for yes.
        /// This option is only supported for a continuous axis.
        /// </summary>
        public bool logScale { get; set; }

        /// <summary>
        /// Position of the horizontal axis text, relative to the chart area. 
        /// Supported values: 'out', 'in', 'none'.
        /// </summary>
        public string textPosition { get; set; }

        /// <summary>
        /// An object that specifies the horizontal axis text style.
        /// The color can be any HTML color string, for example: 'red' or '#00cc00'.
        /// </summary>
        public TextStyle textStyle { get; set; }

        /// <summary>
        /// hAxis property that specifies the title of the horizontal axis.
        /// </summary>
        public string title { get; set; }

        /// <summary>
        /// An object that specifies the horizontal axis text style.
        /// The color can be any HTML color string, for example: 'red' or '#00cc00'.
        /// </summary>
        public TextStyle titleTextStyle { get; set; }

        /// <summary>
        /// If false, will hide outermost labels rather than allow them to be cropped 
        /// by the chart container. If true, will allow label cropping.
        /// This option is only supported for a discrete axis.
        /// </summary>
        public bool allowContainerBoundaryTextCufoff { get; set; }

        /// <summary>
        /// If true, draw the horizontal axis text at an angle, to help fit more text along the 
        /// axis; if false, draw horizontal axis text upright. Default behavior is to slant text 
        /// if it cannot all fit when drawn upright. Notice that this option is available only 
        /// when the hAxis.textPosition is set to 'out' (which is the default).
        /// This option is only supported for a discrete axis.
        /// </summary>
        public bool slantedText { get; set; }

        /// <summary>
        /// The angle of the horizontal axis text, if it's drawn slanted. Ignored if 
        /// hAxis.slantedText is false, or is in auto mode, and the chart decided to draw 
        /// the text horizontally. This option is only supported for a discrete axis. The
        /// range is 1—90.
        /// </summary>
        private double _slantedTextAngle;
        public double slantedTextAngle
        {
            get { return _slantedTextAngle; }
            set 
            {
                if (value > 0 && value < 91)
                {
                    _slantedTextAngle = value;
                }
            }
        }

        /// <summary>
        /// Maximum number of levels of horizontal axis text. If axis text labels become too 
        /// crowded, the server might shift neighboring labels up or down in order to fit 
        /// labels closer together. This value specifies the most number of levels to use; 
        /// the server can use fewer levels, if labels can fit without overlapping.
        /// This option is only supported for a discrete axis.
        /// </summary>
        public double maxAlternation { get; set; }

        /// <summary>
        /// Maximum number of lines allowed for the text labels. Labels can span multiple 
        /// lines if they are too long, and the nuber of lines is, by default, limited by 
        /// the height of the available space.
        /// This option is only supported for a discrete axis.
        /// </summary>
        public double maxTextLines { get; set; }

        /// <summary>
        /// Minimum horizontal spacing, in pixels, allowed between two adjacent text labels. 
        /// If the labels are spaced too densely, or they are too long, the spacing can drop 
        /// below this threshold, and in this case one of the label-unclutter measures will 
        /// be applied (e.g, truncating the lables or dropping some of them).
        /// This option is only supported for a discrete axis.
        /// </summary>
        public double minTextSpacing { get; set; }

        /// <summary>
        /// How many horizontal axis labels to show, where 1 means show every label, 2 means 
        /// show every other label, and so on. Default is to try to show as many labels as 
        /// possible without overlapping. This option is only supported for a discrete axis.
        /// </summary>
        public double showTextEvery { get; set; }

        /// <summary>
        /// hAxis property that specifies the highest horizontal axis grid line. The actual grid 
        /// line will be the greater of two values: the maxValue option value, or the highest 
        /// data value, rounded up to the next higher grid mark.
        /// This option is only supported for a continuous axis.
        /// </summary>
        public double maxValue { get; set; }

        /// <summary>
        /// hAxis property that specifies the lowest horizontal axis grid line. 
        /// The actual grid line will be the lower of two values: the minValue option value, 
        /// or the lowest data value, rounded down to the next lower grid mark.
        /// This option is only supported for a continuous axis.
        /// </summary>
        public double minValue { get; set; }

        /// <summary>
        /// Specifies how to scale the horizontal axis to render the values within the chart area. 
        /// The following string values are supported: 'pretty', 'maximized', 'explicit'
        /// This option is only supported for a continuous axis.
        /// </summary>
        public string viewWindowMode { get; set; }

        /// <summary>
        /// Specifies the cropping range of the horizontal axis.
        /// </summary>
        public ViewWindow viewWindow { get; set; }


        public HorizontalAxis()
        {
            baselineColor = "black";
            direction = 1;
            gridlines = new GridLines();
            minorGridlines = new GridLines(); 
            logScale = false;
            textPosition = "out";
            textStyle = new TextStyle();
            title = null;
            titleTextStyle = new TextStyle();
            allowContainerBoundaryTextCufoff = false;
            slantedText = false;
            slantedTextAngle = 30;
            maxAlternation = 2;
            maxTextLines = 1;
            minTextSpacing = 12;
            showTextEvery = 1;
            viewWindowMode = "pretty";
            viewWindow = new ViewWindow();
        }

    }
}
